home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / x11 / strategy / xpat2-1.000 / xpat2-1 / xpat2-1.04 / src / r_Midnight.c < prev    next >
C/C++ Source or Header  |  1994-09-28  |  3KB  |  94 lines

  1. /*****************************************************************************/
  2. /*                                         */
  3. /*                                         */
  4. /*    X patience version 2 -- module r_Midnight.c                 */
  5. /*                                         */
  6. /*    Characteristics of the ``Midnight Oil'' rules                 */
  7. /*    written by Michael Bischoff (mbi@mo.math.nat.tu-bs.de)             */
  8. /*    04-Apr-1994                                 */
  9. /*    see COPYRIGHT.xpat2 for Copyright details                 */
  10. /*                                         */
  11. /*                                         */
  12. /*****************************************************************************/
  13. #include "xpatgame.h"
  14.  
  15. /* won't work with facedown > 0 */
  16.  
  17. static int MO_new_cards(void) {
  18.     return rules.param[1] > game.counter[1];
  19. }
  20.  
  21.  
  22. /* shuffle the cards */
  23. static Move MO_DealCards(void) {
  24.     int remgraphic;
  25.     int cardsperpile = rules.faceup + rules.facedown;
  26.     Pileindex i;
  27.  
  28.     assert(rules.param[1] > game.counter[1]);
  29.     ++game.counter[1];
  30.  
  31.     /* we are moving a lot, so keep the graphics for later */
  32.     if ((remgraphic = game.graphic))
  33.     graphics_control(Disable);
  34.     store_move(COMPOUND_BEGIN);
  35.  
  36.     /* first, we put all cards on the first slot */
  37.     /* this won't move any game.*/
  38.     for (i = FIRST_SLOT+1; i <= LAST_SLOT; ++i)
  39.     if (!EMPTY(i))
  40.         store_move(do_move(INDEX_OF_FIRST_CARD(i), FIRST_SLOT));
  41.     /* now, we redistribute the cards on the slots */
  42.     /* again, this won't move any game.*/
  43.     for (i = FIRST_SLOT; i <= LAST_SLOT; ++i)
  44.     if (CARDS_ON_PILE(i) > cardsperpile)
  45.         store_move(do_move(INDEX_OF_FIRST_CARD(i)+cardsperpile, i+1));
  46.     else
  47.         break;
  48.     /* now, shuffle the cards */
  49.     store_move(SlotShuffle(1));
  50.     if (remgraphic)
  51.     graphics_control(EnableAndRedraw);
  52.     return COMPOUND_END;
  53. }
  54.  
  55. struct rules MidnightOil_rules = {
  56.     "Midnight Oil",/* shortname */
  57.     NULL,    /* longname */
  58.     "mo",       /* abbrev */
  59.     4,        /* layout_hints */
  60.     0,        /* variant (DECK_SOURCE) */
  61.     CUSTOM_PARAM1|CUSTOM_PARAM3,/* customizable */
  62.     0,        /* customized */
  63.     52,        /* numcards */
  64.     4,        /* numstacks */
  65.     18,        /* numslots */
  66.     0,        /* numtmps */
  67.     1,        /* numdecks */
  68.     13,        /* cards_per_color */
  69.     0,        /* numjokers */
  70.     {0, 2, 0, 1},/* param[1], param[2], param[3] */
  71.     0,        /* facedown */
  72.     3,        /* faceup */
  73.     SEQUENTIAL,    /* newgame_bits */
  74.     NULL,    /* new_game */
  75.     NULL,    /* game_won */
  76.     MO_new_cards,/* new_cards */
  77.     ES_NONE|US_RS|MG_NONE|DC_ALWAYS|ST_ONE, /* move_bits */
  78.     MO_DealCards,/* deal_cards */
  79.     NULL,    /* undeal_cards */
  80.     NULL,    /* stackable */
  81.     NULL,    /* movevalid */
  82.     NULL,    /* valid */
  83.     NULL,    /* relaxed_valid */
  84.     NULL,    /* good_hint */
  85.     NULL,    /* automove */
  86.     NULL,    /* score */
  87.     0,        /* maxscore */
  88.     {0, TXTI_SHUFFLE,/* paramstring 0, 1 */
  89.     0, TXTI_ROTATE},/* paramstring 2,3 */
  90.     0,        /* used */
  91.     NULL,    /* initfunc */
  92.     NULL,    /* local keyboard bindings */
  93. };
  94.